function r(r) {
    return r && r.__esModule ? r : {
        default: r
    };
}

function t(r) {
    if (Array.isArray(r)) {
        for (var t = 0, e = Array(r.length); t < r.length; t++) e[t] = r[t];
        return e;
    }
    return Array.from(r);
}

function e(r) {
    r.$route = function(r) {
        var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "go";
        return s ? Promise.reject("fail:running") : (s = !0, new Promise(function(e, a) {
            var i = {
                success: e,
                fail: a,
                complete: function() {
                    return s = !1;
                }
            };
            if (/^back/.test(r)) {
                var o = r.match(/\d/) || [], u = n(o, 1)[0], c = void 0 === u ? 1 : u;
                t = "back", i.delta = +c;
            } else l[t] || (t = "redirect"), i.url = r;
            l[t](i);
        }));
    }, r.$put = function(r, t) {
        u[r] = t;
    }, r.$take = function(r) {
        var t = u[r];
        return u[r] = null, t;
    }, r.$setData = function(r, t) {
        if ("string" == typeof r) {
            var e = {};
            for (var n in t) t.hasOwnProperty(n) && (e[r + "." + n] = t[n]);
            return this.setData(e);
        }
        if (a.default.isObject(r)) return this.setData(r);
    }, r.$addListener = function() {
        this.$$events = this.$$events || [];
        for (var r = arguments.length, t = Array(r), e = 0; e < r; e++) t[e] = arguments[e];
        return this.$$events.push([].concat(t)), i.default.addListener.apply(i.default, t);
    }, r.$removeListener = function() {
        i.default.removeListener.apply(i.default, arguments);
    }, r.$removeAllListeners = function() {
        this.$$events && this.$$events.forEach(function(r) {
            return i.default.removeListener.apply(i.default, t(r));
        });
    }, r.$emit = i.default.emit;
    var e = r.onUnload, c = r.onLoad;
    return r.onUnload = function() {
        for (var r = arguments.length, t = Array(r), n = 0; n < r; n++) t[n] = arguments[n];
        e && e.call.apply(e, [ this ].concat(t)), this.$removeAllListeners();
    }, r.onLoad = function(r) {
        var t = getApp();
        r && (t.globalData.fromuid = r.fromuid || t.globalData.fromuid, t.globalData.fromapp = r.source || t.globalData.fromapp);
        for (var e = arguments.length, n = Array(e > 1 ? e - 1 : 0), a = 1; a < e; a++) n[a - 1] = arguments[a];
        c && c.call.apply(c, [ this, r ].concat(n)), this.__query = r;
    }, o(r);
}

var n = function() {
    function r(r, t) {
        var e = [], n = !0, a = !1, i = void 0;
        try {
            for (var o, u = r[Symbol.iterator](); !(n = (o = u.next()).done) && (e.push(o.value), 
            !t || e.length !== t); n = !0) ;
        } catch (r) {
            a = !0, i = r;
        } finally {
            try {
                !n && u.return && u.return();
            } finally {
                if (a) throw i;
            }
        }
        return e;
    }
    return function(t, e) {
        if (Array.isArray(t)) return t;
        if (Symbol.iterator in Object(t)) return r(t, e);
        throw new TypeError("Invalid attempt to destructure non-iterable instance");
    };
}(), a = r(require("./util")), i = r(require("./event-emitter"));

try {
    Promise = require("./promise.js");
} catch (r) {
    wx.showModal({
        title: "Promise错误",
        content: "需要更新Promise引入机制"
    }), console.error(r);
}

var o = Page, u = {}, l = {
    go: wx.navigateTo,
    back: wx.navigateBack,
    tab: wx.switchTab,
    redirect: wx.redirectTo,
    relaunch: wx.reLaunch
}, s = !1;

Page = function(r) {
    return e(r);
}, Page.originPage = o;